package cn.com.cifi.mars.constant;

import cn.com.cifi.mars.mapper.mars.SysDictionaryMapper;
import cn.com.cifi.mars.service.SysDictionaryService;
import cn.com.cifi.mars.service.impl.SysDictionaryServiceImpl;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * 明源常用参数
 * @author: JingYuanXiang
 * @date: 2020/12/10 9:39
 */
@Data
@Component
public class MyConstants {

    @Autowired
    private SysDictionaryMapper sysDictionaryMapper;

    //收款类型
    public static final String COLLECTION_FEES = "代收费用";
    public static final String LOANS = "贷款类房款";
    public static final String NOT_LOANS = "非贷款类房款";
    public static final String ELSE = "其它";

    //容差
    private BigDecimal tolerance;

    public BigDecimal getTolerance(String typeCode) {
        String dictValue = sysDictionaryMapper.selectDictValueByTypeCode(typeCode);
        if(StringUtils.isNotBlank(dictValue)){
            this.tolerance = new BigDecimal(dictValue);;
        }
        return tolerance;
    }
}
